<template>
    <div>
        <detail-banner
        :sightName="sightName"
        :bannerImg="bannerImg"
        :gallaryImgs="gallaryImgs"
        ></detail-banner>
        <detail-header></detail-header>
        <detail-intr
        :list="introduceList"
        @change="handleIntrChange"
        @show="handleListShow"
        ></detail-intr>
        <detail-recommend
        :list="recommendList"></detail-recommend>
        <div class="content">
            <detail-list
            :list="list"
            v-show="showDetail"
            >
            </detail-list>
        </div>
    </div>
</template>

<script>
import DetailBanner from './components/banner'
import DetailHeader from './components/header'
import DetailIntr from './components/intr'
import DetailRecommend from './components/recommend'
import DetailList from './components/list'
import axios from 'axios'
export default {
    name: 'Detail',
    components: {
        DetailBanner,
        DetailHeader,
        DetailIntr,
        DetailRecommend,
        DetailList
    },
    data () {
        return {
            sightName: '',
            bannerImg: '',
            gallaryImgs: '',
            list: [],
            recommendList: [],
            introduceList: [],
            showDetail: true,
            num: 0
        }
    },
    mounted () {
        this.getDetailInfo()
    },
    methods: {
        handleIntrChange () {
            this.showDetail = false
        },
        handleListShow () {
            this.showDetail = true
        },
        getDetailInfo () {
            axios.get('/api/detail.json', {
                params: {
                    id: this.$route.params.id
                }
            }).then(this.handleGetDataSucc)
            this.num = parseInt(this.$route.params.id)
        },
        handleGetDataSucc (res) {
            res = res.data
            if (res.ret && res.data) {
                const data = res.data[(this.num) - 1]
                this.sightName = data.sightName
                this.bannerImg = data.bannerImg
                this.gallaryImgs = data.gallaryImgs
                this.list = data.categoryList
                this.recommendList = data.recommendList
                this.introduceList = data.introduceList
            }
        }
    }
}
</script>

<style lang="stylus" scoped>

</style>
